﻿//店铺配置信息
var storeInfo = {
    storeId: getQuery("storeid") == "" ? 0 : getQuery("storeid")
}

//全局接口参数
var siteConfig = {
    //接口域名
    apiDomain: "http://pcapi.711688.net.cn/api/",
    imgDomain: "http://static.711688.net.cn/",
    imgPath: {
        widget: "http://static.711688.net.cn/upload/store/{storeid}/widget/",
        product: "http://static.711688.net.cn/upload/store/{storeid}/product/show/source/",
        news: "http://static.711688.net.cn/upload/news/",
        WeApp: "http://static.711688.net.cn/upload/store/{storeid}/weapp/",
        WeService: "http://static.711688.net.cn/upload/store/{storeid}/weservice/",
        AppCode: ""
    }
}

//全局的接口地址
var siteUrl = {
    //店铺信息
    GetInfo: "api/pc/getinfo?storeid=" + storeInfo.storeId,
    //首页图片A区
    PictureWidgetList_A: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/pc/PictureWidgetConfigList?code=pc_index_pic_a&storeid=" + storeInfo.storeId),
    //首页图片B区
    PictureWidgetList_B: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/pc/PictureWidgetConfigList?code=pc_index_pic_b&storeid=" + storeInfo.storeId),
    //内容组件列表
    NewsWidgetList: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/pc/NewsWidgetConfigList?&storeid=" + storeInfo.storeId),
    //新品、热销、精品推荐
    ProductWidgetList: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/store/GetWidgetList?code=index_product&storeid=" + storeInfo.storeId),
    //导航条
    NavWidgetList: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/store/GetWidgetList?code=pc_index_nav&storeid=" + storeInfo.storeId),
    //轮播banner
    IndexBanner: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/store/GetWidgetList?code=pc_index_banner&storeid=" + storeInfo.storeId),
    //店铺分类
    StoreClassList: "api/store/getclasslist?catid=0&store_id=" + storeInfo.storeId,
    //产品列表
    ProductList: "api/store/Search?page=1&cateid={cateid}&storeid=" + storeInfo.storeId,
    //产品详情
    ProductDetail: "api/store/product?pid={pid}",
    //内容详情
    NewsDetail: "api/news/Details?newsid={newsid}",
    //内容列表
    NewsList: "api/news/NewsList?newstypeid={newstypeid}&newsTitle=&storeid=" + storeInfo.storeId,
    //产品太阳码
    ProductAppCode: "api/pc/productappcode?pid={pid}",
    //关于我们
    About: "api/store/getinfo?id=" + storeInfo.storeId,
    //添加留言
    AddConsult: "api/pc/usermsg?storeid=" + storeInfo.storeId,
    //取店铺ID
    GetStoreIdByWebsite: "api/pc/getstoreidbywebsite?website={website}",

    fotmatUrl: function (path) {
        return siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent(path);
    },

    htmlUrl: {
        //商品列表
        ProductList: "/pages/product.html?storeid={storeid}&linktype=store_class&linkid={linkid}",
        //商品详情
        ProductDetail: "product_item.html?storeid={storeid}&linktype=product&pid={pid}",
        //内容列表
        NewsList: "/pages/news.html?storeid={storeid}&linktype=news_type&linkid={linkid}",
        //内容详情
        NewsDetail: "/pages/news_item.html?storeid={storeid}&linktype=news&newsid={newsid}",
    },



    //发送验证码
    sendCode: siteConfig.apiDomain + "home/sendcode",
    //提交用户联系信息  
    subusermsg: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/pc/usermsg?"),
    //案例api/Consult/usermsg",
    getNewsList: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/store/getinfo?id=" + storeInfo.storeId),
    //得到顶部轮播的信息
    Getwidgetconfig: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/pc/Getwidgetconfig?"),
    //得到图片组件的信息
    GetIndexpictureConfig: siteConfig.apiDomain + "home/json?mothod=" + encodeURIComponent("api/pc/GetIndexpictureConfig?")
}

//全局的json状态码
var jsonCode = {
    success: 0,
    error: 501
}

//URL参数
function getQuery(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = decodeURI(window.location.search).substr(1).match(reg);
    if (r != null)
        return unescape(r[2]);
    return "";
}
